import threading
from SOAPpy import Server
from SOAPpy import WSDL

SOCF_BASE_NS = "http://code.google.com/p/socf"

class ServiceContainer(threading.Thread):
    
    def __init__(self,  ip='localhost', port=8888):
        self.__ip = ip
        self.__port = port
        self.__server = Server.SOAPServer((self.__ip, self.__port))
        threading.Thread.__init__(self)
        self.setDaemon(True)
        
    def addServiceObject(self,  obj,  name):
        self.__server.registerKWObject(obj, SOCF_BASE_NS + "/" + name)
        return "http://" + str(self.__ip) + ":" + str(self.__port) + "/"  + name
        
    def run(self):
        self.__server.serve_forever()
        
    def stop(self):
        self.__server.shutdown()
        
class ServiceClient(WSDL.Proxy):

    def __init__(self,  url):
        WSDL.Proxy.__init__(self, url)

    
    
